from fastapi import FastAPI
from app.db.database import Base, engine
from app.controllers.auth_controller import router as auth_router
from app.controllers.user_controller import router as user_router
from app.config import setup_cors
import uvicorn
app = FastAPI()

# 初始化数据库
Base.metadata.create_all(bind=engine)

# 配置 CORS
setup_cors(app)

# 注册路由
app.include_router(auth_router, prefix="/auth", tags=["Auth"])
app.include_router(user_router, prefix="/users", tags=["Users"])

@app.get("/")
def read_root():
    return {"message": "Welcome to the FastAPI application"}

#if __name__ == "__main__":
    #uvicorn main:app --reload
    #uvicorn.run("__main__:app", host="127.0.0.1", port=5003, log_level="info", reload=True)